<include file="__THEME__/public_header" />

<div id="page-wrap">
    <div id="main-wrap">
    	<div id="st-index-grid" class="st-grid">
            <div id="col8" class="st-section boxShadow content-bg">
            	<include file="__THEME__/public_right" />
                <div id="col5" class="st-index-main">
                <div class="extend-foot">
				<!--tab menu-->
                <div class="feed-nav clearfix">
                	<div class="my-feed-title">
                		<span class="right">
                            <!-- <form action="{:U('public/Index/following', array('follow_key'=>$follow_key))}" method="GET" id="searchfollow"> -->
                            <div class="feed-search">
	                            <input type="hidden" name="gid" value="{$gid}" />
	                            <input class="s-txt left"  type="text" name='follow_key' value="{$follow_key}" id='follow_key'>
	                            <a href="javascript:;" class="ico-search left" onclick="doSearchKey('{$gid}')"></a>
                            </div>
                            <!-- </form> -->
                        </span>
                		<h4 class="left">我关注的人(共<span id="follow_count" event-node="following_count" event-args="uid={$GLOBALS['ts']['mid']}">{$followingCount|default=0}</span>人)</h4>
                		</div>
					    <div class="mod-feed-tab mt10 clearfix" id="mod-feed-tab" <php>if(!isset($_GET['feed_type']) && empty($_GET['feed_key'])){</php><php>}</php> >
	                        <span class="right"><a class="btn-att-green mr5" href="javascript:;" event-node="addFollowgroup"><i class="ico-add-white"></i>创建分组</a><a class="btn-att-green" href="javascript:;" event-node="editFollowgroup">管理分组</a>
						    </span>
	                        <ul class="inner-feed-nav">
	                        	<volist name="groupList" id="vo" offset="0" length="$groupNums">
	                        		<li <eq name="gid" value="$vo['gid']">class="current"</eq>><a title="{$vo['title']}" href="{:U('public/Index/following', array('gid'=>$vo['gid'],'follow_key'=>$follow_key))}">{$vo['title']}</a></li>
	                        	</volist>
	                        	<php>if(!in_array($gid, $topGroup)):</php>
	                        	<li class="current"><a title="{$gTitle}" href="{:U('public/Index/following', array('gid'=>$gid,'follow_key'=>$follow_key))}">{$gTitle}</a></li>
	                        	<php>elseif(count($groupList) > $groupNums):</php>
	                        	<li <eq name="gid" value="$groupList[$groupNums]['gid']">class="current"</eq>><a title="{$groupList[$groupNums]['title']}" href="{:U('public/Index/following', array('gid'=>$groupList[$groupNums]['gid'],'follow_key'=>$follow_key))}">{$groupList[$groupNums]['title']}</a></li>
	                        	<php>endif;</php>
	                    		<php>if(count($groupList) > $groupNums + 1):</php>
	                    		<li><a href="javascript:;" event-node="more_follow_group">更多</a></li>
	                    		<php>endif;</php>
	                        </ul>
                    	</div>
                	

					<div class="sperson-feedlist" >
					<php>if($data){</php>
						<volist name="data" id="vo">
							<dl class="feed_list" model-node="following_list_item">
								<dt class="face">
								   <a href="{$vo.space_url}"><img title="{$vo.uname}" src="{$vo.avatar_small}" width="50" height="50"/></a></dt>
								<dd class="person-info">
								  <div class="info-right right">
										{:W('FollowGroup', array('uid'=>$mid, 'fid'=>$vo['uid'], 'follow_group_status'=>$followGroupStatus[$vo['uid']], 'tpl'=>'btn'))}
										<span class="right">{:W('FollowBtn', array('fid'=>$vo['uid'], 'uname'=>$vo['uname'], 'follow_state'=>$vo['followState'], 'refer'=>'following_list'))}</span>
								  </div>
								  <div class="info-left">
									<p class="hd">
										<a class="follow_uname" href="{$vo['space_url']}" event-node='face_card' uid="{$vo['uid']}" style="font-size:14px">{$vo.uname}</a>
										<volist name="userGroupData[$vo['uid']]" id="v1">
                                			<img style="width:auto;height:auto;display:inline;cursor:pointer;vertical-align:-3px" src="{$v1['user_group_icon_url']}" title="{$v1['user_group_name']}" />&nbsp;
                              			</volist>
										{:W('Remark', array('uid'=>$vo['uid'], 'remark'=>$vo['remark']))}	
									</p>
									<p class="area"><span><if condition="$vo.sex eq 1"><i class="ico-male"></i><else /><i class="ico-female"></i></if>&nbsp;{$vo.location}</span></p>
									<p class="action">									
										{:L('PUBLIC_FOLLOWING')}：<a href="{:U('public/Profile/following', array('uid'=>$vo['uid']))}">{$vo.following_count|default=0}</a>
										<i class="vline">|</i>
										{:L('PUBLIC_FOLLOWERS')}：<a href="{:U('public/Profile/follower', array('uid'=>$vo['uid']))}">{$vo.follower_count|default=0}</a>
										<i class="vline">|</i>
										{:L('PUBLIC_WEIBO')}：<a href="{:U('public/Profile/index', array('uid'=>$vo['uid']))}">{$vo.feed_count|default=0}</a>
									</p>
									<php>if($vo['intro']){</php>
										<p class="info">
											{:L('PUBLIC_PROFILESET_INTRO')}：{$vo.intro}
										</p>
									<php>}</php>
									<php>if($user_tag[$vo['uid']]){</php>
										<p class="info">
											{:L('PUBLIC_TAG')}：<volist name="user_tag[$vo['uid']]" id="u_t_v"><a href="{:U('public/Search/index',array('t'=>3,'a'=>'public','k'=>$u_t_v))}">{$u_t_v}</a>&nbsp;&nbsp;&nbsp;</volist>
										</p>
									<php>}</php>
								  </div>	
								</dd>
							</dl>	
						</volist>
						<div id="page" class="page">{$html}</div>
					<php>}elseif($follow_key !== '' && !is_null($follow_key)){</php>
						<div class="loading">抱歉，暂时没有找到与 “{$follow_key}” 相关的结果</div>
					<php>}else{</php>
                        <div class="loading">你还没有关注任何人</div>
                    <php>}</php>
					</div>
                </div>
                </div>
            	</div>
        	</div>
    	</div>
	</div>
</div>

<script type="text/javascript" src="__THEME__/js/module.weibo.js"></script>
<script type="text/javascript">
// 事件监听
M.addEventFns({
	more_follow_group: {
		load: function() {
			var offset = $(this).offset();
			var top = offset.top + 22;
			var left = offset.left;
			var list = "";
	        <volist name="groupList" id="vo" offset="$groupNums">
	        <php>if($gid != $vo['gid']):</php>
	        	<php>if($i !== 1 || !in_array($gid, $topGroup)):</php>
	        		list += '<li><a title="{$vo['title']}" href="{:U('public/Index/following', array('gid'=>$vo['gid'],'follow_key'=>$follow_key))}">{$vo['title']}</a></li>';
	        	<php>endif;</php>
	        <php> endif;</php>
	        </volist>
			var html = '<div id="more_follow_group" class="layer-list" style="display:none;position:absolute;top:'+top+'px;left:'+left+'px;">\
						<ul>'+list+'</ul>\
				        </div>';
			$("body").append(html);
		},
		click: function() {
			if($('#more_follow_group').css('display') == 'none') {
				$('#more_follow_group').css('display', '');
			} else {
				$('#more_follow_group').css('display', 'none');
			}
		}
	}
});


/**
 * 高亮Js
 * @param  {[type]} a [description]
 * @param  {[type]} b [description]
 * @return {[type]}   [description]
 */
var doHighlight = function (a, b) {
    highlightStartTag = "<span style='color:red;font-size:14px'>";
    highlightEndTag = "</span>";
    var c = "";
    var i = -1;
    var d = b.toLowerCase();
    var e = a.toLowerCase();
    while (a.length > 0) {
        i = e.indexOf(d, i + 1);
        if (i < 0) {
            c += a;
            a = "";
        } else {
            if (a.lastIndexOf(">", i) >= a.lastIndexOf("<", i)) {
                if(e.lastIndexOf("/script>",i)>=e.lastIndexOf("<script",i)){
                    c+=a.substring(0,i)+highlightStartTag+a.substr(i,b.length)+highlightEndTag;
                    a=a.substr(i+b.length);e=a.toLowerCase();
                    i=-1;
                }
            }
        }
    }
    return c;
};
/**
 * 添加Jquery方法
 * @param  {[type]} z [description]
 * @return {[type]}   [description]
 */
$.fn.highlight=function(z){
    $(this).each(
        function(){
            $(this).html(doHighlight($(this).html(),z))
        });
    return this;
}
/**
 * 绑定高亮
 * @return {[type]} [description]
 */
$(document).ready(function(){
	var key3 = $.parseJSON('{$jsonKey}');
	$('.follow_uname').highlight(key3);
}); 

var doSearchKey = function (gid) {
	location.href = U('public/Index/following') + '&follow_key=' + $.trim($('#follow_key').val()) + '&gid=' + gid;
	return false;
}
</script>

<include file="__THEME__/public_footer" />